﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Rotempco.BaseClass.Objects.EntityObjects;
using Rotempco.BaseClass;
using Rotempco.Core.Logic;
using Rotempco.Website.Logic;
using Rotempco.Website.WebPages.Admin.Users.Extensions;
using Rotempco.Website.WebPages.Admin.Users.Managers;
using Rotempco.Core.Web.CRUD.Objects;
using Rotempco.Core.Web.CRUD.ACRUD;
using Rotempco.Core.Web.CRUD.Logic;
using Rotempco.Core.Web.CRUD.Objects.Enums;
using Rotempco.Core.Web.Logic;
using Rotempco.Core.ORM.Objects;
using Rotempco.BaseClass.Objects.AttributeStoreObjects;

namespace Rotempco.Website.WebPages.Admin.Users
{
    public partial class Default : ACRUDDefaultMultiColumn
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public override PageListMultiColumnContainer GetPageListContainer()
        {
            PagingContainer pagingContainer = PagingContainerHelper<LoginUser>.GetPagingContainer((LoginUser e) => e.Name);

            List<LoginUserExtension> loginUserExtensionList = LoginUserExtensionManager.Instance.GetAll(pagingContainer);

            return PageListMultiColumnContainerHelper.GenerateContainer<LoginUserExtension>(
                loginUserExtensionList,
                new List<MultiColumnOptions>()
                { 
                    new MultiColumnOptions()
                    {
                        Header = "Name",
                        DisplayName = PropertyLogic.GetPropertyName((LoginUserExtension l) => l.Name),
                        SortColumnOptions = PageListMultiColumnContainerHelper.SortColumnOptions((LoginUser e) => e.Name),
                        CellAlign = AlignTypeEnum.Left,
                        CellWidthInPx = 385,
                    },
                    new MultiColumnOptions()
                    {
                        Header = "",
                        DisplayName = "Reset password",
                        CellAlign = AlignTypeEnum.Right,
                        CellWidthInPx = 200,
                        LinkOptions = new LinkOptions()
                        {
                            Url = UrlLogic.GetStaticBaseUrl() + "/ResetPassword.aspx",
                            IdentifierName = PropertyLogic.GetPropertyName((LoginUser l) => l.LoginUserId)
                        },
                        LinkIcon = LinkIconEnum.Edit
                    },
                    new MultiColumnOptions()
                    {
                        Header = "",
                        DisplayName = "Edit",
                        CellAlign = AlignTypeEnum.Right,
                        CellWidthInPx = 75,
                        LinkOptions = new LinkOptions()
                        {
                            Url = UrlLogic.GetStaticBaseUrl() + "/Edit.aspx",
                            IdentifierName = PropertyLogic.GetPropertyName((LoginUser l) => l.LoginUserId)
                        },
                        LinkIcon = LinkIconEnum.Edit
                    },
                    new MultiColumnOptions()
                    {
                        Header = "",
                        DisplayName = "Delete",
                        CellAlign = AlignTypeEnum.Right,
                        CellWidthInPx = 75,
                        LinkOptions = new LinkOptions()
                        {
                            Url = UrlLogic.GetStaticBaseUrl() + "/Delete.aspx",
                            IdentifierName = PropertyLogic.GetPropertyName((LoginUserExtension l) => l.LoginUserId),
                            ConfirmBeforeRedirect = true,
                            ConfirmMessage = "Are you sure you want to delete the user?"
                        },
                        LinkIcon = LinkIconEnum.Delete
                    }
                },
                pagingContainer: pagingContainer,
                hideAddNewButton: false,
                pageTitle: "Users"
            );
        }

    }
}
